package com.wmyg.scanninggun.service.impl;

import com.wmyg.scanninggun.bean.Factory;
import com.wmyg.scanninggun.bean.FactoryDevice;
import com.wmyg.scanninggun.dao.FactoryDeviceMapper;
import com.wmyg.scanninggun.dao.FactoryMapper;
import com.wmyg.scanninggun.service.FactoryDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class FactoryDeviceServiceImpl implements FactoryDeviceService {

    @Autowired
    FactoryMapper factoryMapper;

    @Autowired
    FactoryDeviceMapper factoryDeviceMapper;

    @Override
    public Factory getFactoryByDeviceId(String deviceId) {
        FactoryDevice factoryDevice = factoryDeviceMapper.selectByDeviceId(deviceId);
        if (null == factoryDevice) {
            return null;
        }
        Factory factory = factoryMapper.view(factoryDevice.getFactoryId());
        return factory;
    }
}
